package cn.test.learnkotlin.v1

private class KEnumerate {

    enum class Color {
        GREEN, BLUE, RED
    }

    enum class Color1(val color: Int) {
        RED(0xFF0000),
        BLUE(0x0000ff),
        GREEN(0x00ff00),
    }

    fun fooColor() {
        for (value in Color1.values()) {
            println("${value.name} form Color1, color:${value.color} ,ordinal:${value.ordinal}")
        }
    }

    enum class ProtocolState {

        WAITING {
            override fun signal() = RUNNING
        },

        RUNNING {
            override fun signal() = WAITING
        },
        ;

        abstract fun signal(): ProtocolState
    }

    fun fooEnumValues() {
        for (value in enumValues<ProtocolState>()) {
            println("${value.name} from ProtocolState ,ordinal:${value.ordinal}")
        }
    }

    fun main() {
        fooEnumValues()
    }
}

fun main() {
    KEnumerate().main()
}